<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>-
<%@ taglib prefix="aa" uri="/WEB-INF/tld/ajaxanywhere.tld" %>
<%@ taglib prefix="mytag" tagdir="/WEB-INF/tags" %>
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport"
	content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>jsp1</title>
<script src="/webjars/jquery/3.5.1/jquery.js"></script>
<script src="/aa.js"></script>
<link rel="stylesheet" href="/resources/css/bootstrap.min.css" />
<link rel="stylesheet" href="/resources/css/dashboard.css" />
<%@include file="./dialog/dialog.jsp"%>
</head>
<body>
<div class="modal-body">
 <input type="hidden"  value='${callBack}' id="callBack">
 <aa:zone name="zoneP">
	 <div>
	   <c:forEach var="o" items="${pagelist}" varStatus="s">
	    <div class="form-check">
		  <input class="form-check-input" type="radio" name="flexRadioDefault" value='{"id":"${o.id}","name":"${o.name}"}' id="${o.id}">
		  <label class="form-check-label" for="${o.id}">
		    ${(currentPage-1)*pageSize+s.index+1} , id: ${o.id} , name: ${o.name} ,createDate: ${o.createDate}
	      </label>
	 </div>
     </c:forEach>
  </div>
   <mytag:Page id="pagetest" count="${fn:length(list)}" pageSize="${pageSize}" currentPage="${currentPage}" useCallback="true" pageCallback="getPageList"/>
 </aa:zone>
 </div>
 <div class="modal-footer">
        <button type="button" class="btn btn-secondary" onclick="cancledialog();">关闭</button>
        <button type="button" class="btn btn-primary" onclick="confirmDemo();">确定</button>
 </div>
</body>
<script type="text/javascript">
 $('#btPageQuery').click(function() {
  ajaxAnywhere.getAJAX('/j/pageListDemo?pageSize=10&currentPage=1', 'zoneP');
 });
 
 
 function getOpener (){
	if(opener){
			return opener.window; 
	}else {
			return parent.window;
	}
}

/*选择按钮*/
function confirmDemo(){
	var idsArray=[];
	//在父页面定义一个  函数,获取选中的值 transmit传递
	if ($("input[name='flexRadioDefault']:checked").length == 0){
		  alert("请选择一条记录！");
		  return false;
     }
	else{
	     var objs=$("input[name='flexRadioDefault']:checked").val([]);
	     objs.each(function (){
	    	 idsArray.push(this.value);
	     });
	}
	if(getOpener()){
	    var callBack = $("#callBack").val();
		eval("getOpener()."+callBack+"(JSON.parse(idsArray[0]))");		//传递一个对象
	}
}

function cancledialog(){
	if(getOpener()){
		getOpener().dialogCancel();
	}
}

</script>
<script src="/resources/js/http.js"></script>
</html>
